#include "StdAfx.h"
#include "BufferKeeper.h"


BufferKeeper::BufferKeeper(int inInitialReservation, int inSizeOfElement)
	: mCapacity(inInitialReservation * inSizeOfElement),
	mBuffer(::malloc(mCapacity))
{
}


BufferKeeper::~BufferKeeper(void)
{
	if (NULL != mBuffer)
	{
		::free(mBuffer);
	}
}

void BufferKeeper::AllocateSize(int inCapacity)
{
	if (NULL != mBuffer)
	{
		if (inCapacity <= mCapacity)
		{
			return;
		}
		::free(mBuffer);
	}
	mBuffer = ::malloc(inCapacity);
}